package org.liveboardgames.agricola.control.delegates.mock.cards.actioncards
{
    import org.liveboardgames.agricola.control.delegates.mock.ActionFactory;
    import org.liveboardgames.agricola.model.enums.ActionOutputEnum;
    import org.liveboardgames.agricola.model.enums.HouseTypeEnum;
    import org.liveboardgames.agricola.model.enums.ResourceZoneEnum;
    import org.liveboardgames.agricola.view.component.ImageHandler;
    import org.liveboardgames.agricola.vo.action.Action;
    import org.liveboardgames.agricola.vo.card.ActionCard;
    
    import mx.collections.ArrayCollection;
    import mx.collections.ListCollectionView;
    
    public class FamilyBoardCards
    {
        public static const ROOM_ANDOR_STABLE:ActionCard = getRoomStableCard();
        
        public static const FIRST_PLAYER_AND_FOOD:ActionCard = getFirstPlayerFoodCard();
        
        public static const ONE_GRAIN:ActionCard = getOneGrainCard();
        
        public static const PLOUGH:ActionCard = getPloughCard();
        
        public static const STABLE_ANDOR_BAKE:ActionCard = getStableBakeCard();
        
        public static const DAILY_LABORER:ActionCard = getDailyLaborerCard();
        
        private static function getRoomStableCard():ActionCard
        {
            var card:ActionCard = new ActionCard();
            card.cardName = "Build room and stable";
            
            // Build the actions
            var actions:ListCollectionView = new ArrayCollection();
            
            // Get three actions for the room, the processor will need to 
            // decide which ones to filter out
            var woodenRoomAction:Action = ActionFactory.getRoomAction(HouseTypeEnum.WOODEN);
            var clayRoomAction:Action = ActionFactory.getRoomAction(HouseTypeEnum.CLAY);
            var stoneRoomAction:Action = ActionFactory.getRoomAction(HouseTypeEnum.STONE);
            
            // 0 for unlimited numbre of uses (limited by the stables not 
            // played yet)
            var stableAction:Action = ActionFactory.getStableAction(2, 0);
            
            actions.addItem(woodenRoomAction);
            actions.addItem(clayRoomAction);
            actions.addItem(stoneRoomAction);
            actions.addItem(stableAction);
            
            card.actions = actions;
            
            return card;
        }
        
        private static function getFirstPlayerFoodCard():ActionCard
        {
            var card:ActionCard = new ActionCard();
            card.cardName = "First player";
            card.resourceZone = ResourceZoneEnum.RIGHT;
            
            // Build the actions
            var actions:ListCollectionView = new ArrayCollection();
            
            var firstPlayerAction:Action = ActionFactory.getFirstPlayerAction();
            var foodAction:Action = ActionFactory.getResourceAction(ActionOutputEnum.FOOD, 1, true);
            foodAction.target = card;
            foodAction.needPlayerInput = false;
            var takeAction:Action = ActionFactory.getTakeAllAction(card);
            
            actions.addItem(firstPlayerAction);
            actions.addItem(foodAction);
            actions.addItem(takeAction);
            
            card.actions = actions;
            
            return card;
        }
        
        private static function getOneGrainCard():ActionCard
        {
            var card:ActionCard = new ActionCard();
            card.cardName = "One grain";
            
            // Build the actions
            var actions:ListCollectionView = new ArrayCollection();
            var action:Action = ActionFactory.getResourceAction(ActionOutputEnum.GRAIN, 1, false);
            action.needPlayerInput = false;
            
            actions.addItem(action);
            
            card.actions = actions;
            
            return card;
        }
        
        private static function getPloughCard():ActionCard
        {
            var card:ActionCard = new ActionCard();
            card.cardName = "Plough";
            
            // Build the actions
            var actions:ListCollectionView = new ArrayCollection();
            var action:Action = ActionFactory.getPloughAction();
            actions.addItem(action);
            
            card.actions = actions;
            
            return card;
        }
        
        private static function getStableBakeCard():ActionCard
        {
            var card:ActionCard = new ActionCard();
            card.cardName = "Bake and stable";
            
            // Build the actions
            var actions:ListCollectionView = new ArrayCollection();
            var stableAction:Action = ActionFactory.getStableAction(1, 1);
            var bakeAction:Action = ActionFactory.getBakeAction();
            actions.addItem(stableAction);
            actions.addItem(bakeAction);
            
            card.actions = actions;
            
            return card;
        }
        
        private static function getDailyLaborerCard():ActionCard
        {
            var card:ActionCard = new ActionCard();
            card.cardName = "Daily laborer";
            
            // Build the actions
            var actions:ListCollectionView = new ArrayCollection();
            var action1:Action = ActionFactory.getResourceAction(ActionOutputEnum.FOOD, 1, false);
            action1.needPlayerInput = false;
            var action2:Action = ActionFactory.getResourceAction(ActionOutputEnum.CHOICE_RESOURCE, 1, false);
            actions.addItem(action1);
            actions.addItem(action2);
            
            card.actions = actions;
            
            return card;
        }
    
    }
}